<nav class="navbar-default navbar-static-side" role="navigation" style="margin-top: 60px;">
	<div class="sidebar-collapse">
		<ul class="nav metismenu" id="side-menu">
			<!-- brand -->
			<li class="nav-header">
				<div class="profile-element text-center" style="color: #fff;">
					<p class="block"> <strong><%= Time.zone.now.strftime("%A %R %p")%></strong></p>
					<% if @room.present? %>
						<span class="label label-primary"><%= @room.name %></span>
					<% end %>
				</div>
				<div class="logo-element logo-wrapper">
					iGrid
				</div>
			</li>
			<% if @room.present? %>
				<li class="<%= "active" if params[:controller] == 'rooms' && params[:action] == 'show' %>">
					<%= link_to room_path(@room) do %>
						<i class="fa fa-th-large"></i> <span class="nav-label">主界面</span></span>
					<% end %>
				</li>

				<!-- 一级菜单 -->
				<% @room.systems.each do |system| %>
					<li class="<%= 'active' if params[:controller] == 'devices' && system == @device.try(:pattern).try(:sub_system).try(:system) %>" >
						<%= link_to '#' do %>
							<i class="fa <%= menu_tree_icon(system.name) %>"></i> <span class="nav-label"><%= system.name %></span>
							<%= '<span class="fa arrow"></span>'.html_safe if @room.sub_systems_by_system(system).present? %>
						<% end %>
						<!-- 二级菜单 -->
						<%= '<ul class="nav nav-second-level collapse">'.html_safe if @room.sub_systems_by_system(system).present? %>
						<% @room.sub_systems_by_system(system).each do |sub_system| %>
							<li class="<%= 'active' if params[:controller] == 'devices' && sub_system == @device.try(:pattern).try(:sub_system) %>">
								<%= link_to '#' do %>
									<%= sub_system.name %>
									<%= '<span class="fa arrow"></span>'.html_safe if sub_system.devices.by_room(@room.id).present? %>
								<% end %>
								<!-- 三级菜单 -->
								<%= '<ul class="nav nav-third-level collapse">'.html_safe if sub_system.devices.by_room(@room.id).present? %>
								<% sub_system.devices.by_room(@room.id).each do |device| %>
									<li  class="<%= 'active' if params[:controller] == 'devices' && device == @device %>">
										<%= link_to device.name, room_device_path(@room, device) %>
									</li>
								<% end %>
								<%= '</ul>'.html_safe if sub_system.devices.by_room(@room.id).present? %>
								<!-- 三级菜单 -->
							</li>
						<% end %>
						<%= '</ul>'.html_safe if @room.sub_systems_by_system(system).present? %>
						<!-- 二级菜单 -->
					</li>
				<% end %>
				<li class="<%= "active" if params[:controller] == "reports" && params[:action] == 'index' %>">
				  <%= link_to room_reports_path(@room) do %>
				    <i class="fa fa-area-chart"></i>
				    <span class="nav-label">报表</span>
				  <% end %>
			  </li>
				<li class="<%= "active" if params[:action] == 'alert' %>">
				  <%= link_to alert_room_path(@room) do %>
				    <i class="fa fa-list-ul"></i>
				    <span class="nav-label">告警记录</span>
				  <% end %>
			  </li>
			  <li class="<%= "active" if params[:action] == 'video' %>">
				  <%= link_to video_room_path(@room) do %>
				    <span class="fa fa-video-camera"></span>
				    <span class="nav-label">&nbsp;&nbsp;摄像头</span>
				  <% end %>
			  </li>
			  <li class="<%= "active" if params[:action] == 'pic' %>">
				  <%= link_to pic_room_path(@room) do %>
				    <i class="fa fa-file-image-o"></i>
				    <span class="nav-label">告警图片</span>
				  <% end %>
			  </li>
				<!-- 一级菜单 -->
			<% end %>
		</ul>
	</div>
</nav>